const webpack = require('webpack')
const path = require('path')

const vendors = [
  'polyfill.min.js',
  'fetch.min.js',
  'weixinapi.min.js',
  'modules/egret/egret.min.js',
  'modules/egret/egret.web.min.js',
  'modules/res/res.min.js',
  'modules/eui/eui.min.js'
]

module.exports = {
  resolve: {
    modules: [
      path.join(__dirname, 'src/lib')
    ],
    extensions: ['.js', '.css', '.less', '.ts'],
  },
  context: path.join(__dirname, 'lib'),
  output: {
    path: path.join(__dirname, 'src/lib'),
    filename: '[name].[hash:5].js',
    library: '[name]_[hash:5]',
  },
  entry: {
    vendor: vendors,
  },
  plugins: [
    new webpack.DllPlugin({
      path: 'manifest.json',
      name: '[name]_[hash:5]',
      context: __dirname,
    }),
    new webpack.optimize.UglifyJsPlugin({
      mangle: true,
      compress: {
        warnings: false, // 禁止生成warning
        drop_debugger: true,
        drop_console: true
      }
    })
  ],
};